#ifndef SUPPORTEDSERVICESDB_H
#define SUPPORTEDSERVICESDB_H

#include "CoreFarmAPI.h"



///////////////////////////////////////////////////////////////
//////Supported Services NODE AND METHODS//////////////////////
///////////////////////////////////////////////////////////////

typedef struct SupportedServicesNode{

	char serviceName[SERVICE_NAME_LENGTH];
	int serviceID;
	struct SupportedServicesNode* next;

}SupportedServicesNode;

SupportedServicesNode* SupportedServicesNodeConstructor(){

	SupportedServicesNode *thisNode;

	thisNode = (SupportedServicesNode*)malloc(sizeof(SupportedServicesNode));
	assertMem(thisNode);

	thisNode->serviceID = 0;
	thisNode->next = NULL;

	return thisNode;
}

void supportedServicesNodeSetserviceID( SupportedServicesNode *thisNode, int _serviceID) { thisNode->serviceID =_serviceID ; }
void supportedServicesNodeSetServiceName( SupportedServicesNode *thisNode, char *_Name) { strcpy( thisNode->serviceName, _Name ) ;}
void supportedServicesNodeSetNext( SupportedServicesNode *thisNode, SupportedServicesNode *_next) { thisNode->next = _next ;}
char *supportedServicesNodeGetServiceName( SupportedServicesNode *thisNode) {return thisNode->serviceName ;}
int supportedServicesNodeGetServiceID( SupportedServicesNode *thisNode) {return thisNode->serviceID ;}
SupportedServicesNode * supportedServicesNodeGetNext( SupportedServicesNode *thisNode) { return thisNode->next ;}

///////////////////////////////////////////////////////////////////////////////////////////
//////// SupportedServices Database List structure and methods ////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////

typedef struct SupportedServicesDB{

	int size;
	SupportedServicesNode *head;

}SupportedServicesDB;

SupportedServicesDB *supportedServices_DB = NULL;

void supportedServicesDBConstructor(){
	supportedServices_DB = (SupportedServicesDB*)malloc(sizeof(SupportedServicesDB));
	assertMem(supportedServices_DB);

	supportedServices_DB->size = 0;
	supportedServices_DB->head = NULL;
}

void supportedServicesDBSetHead(SupportedServicesNode *_head){ supportedServices_DB->head = _head ;}
SupportedServicesNode* supportedServicesDBGetHead(){ return supportedServices_DB->head ;}
int SupportedServicesDBGetSize(){ return(supportedServices_DB->size); }
int supportedServicesDBIsEmpty(){ return (supportedServices_DB->size == 0) ;}

void supportedServicesDBPush(char *serviceName, int serviceID){

	SupportedServicesNode *newSupportedServices = SupportedServicesNodeConstructor();

	supportedServicesNodeSetServiceName( newSupportedServices, serviceName);
	supportedServicesNodeSetserviceID( newSupportedServices, serviceID);

	if ( !supportedServices_DB )
		supportedServicesDBConstructor();

	if( !supportedServicesDBIsEmpty() )
		newSupportedServices->next = supportedServices_DB->head;

	supportedServices_DB->head = newSupportedServices;
	supportedServices_DB->size++;
}


void supportedServicesPrintAll(){
	SupportedServicesNode *currNode = NULL;

	if ( supportedServices_DB )
		currNode = supportedServices_DB->head;
	while( currNode ){
		printf("serviceID: %d \n SupportedServicess:\n %s\n",currNode->serviceID, currNode->serviceName);
		currNode = currNode->next;
	}//while
}//support service PrintALL


#endif